/**
 * Date:2019年4月4日 上午11:53:52
 * Copyright (c) 2019, www.bwbroad.com All Rights Reserved
 */

package com.xue.service.sys;
/**
 * Description: TODO <br/> 
 * Date:2019年4月4日 上午11:53:52 <br/> 
 * @author xuejianxin
 */

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.xue.pojo.sys.SysCode;

@Component("sysCode")
public class SysCodeImpl implements ICode {
	@Autowired
	private ISysCodeService sysCodeService;

	@Override
	public Map<String, Object> codeMap(String options) {
		return sysCodeService.queryByCodeType(options).stream()
				.collect(Collectors.toMap(SysCode::getCode, SysCode::getCodeName, (k1, k2) -> {
					throw new RuntimeException(String.format("Duplicate key for values %s and %s", k1, k2));
				}, LinkedHashMap::new));
	}

	@Override
	public String codeType() {
		return "0";
	}

}
